#ifndef NSURVEYOR_H
#define NSURVEYOR_H
#include <QtWidgets>
#include "tools/Gadget.h"

class NProcess : public QWidget{

    Q_OBJECT

public:
    NProcess(QWidget *parent=nullptr, bool _wingsgraph=true){
        setParent(parent);
        setFormat("%1\%");
        setProperty("graph-prograss", 0);
        setProperty("prograss-minnum", 0);
        setProperty("prograss-maxnum", 100);
        setProperty("prograss-step", 1);
        setProperty("graph-prograss-radius", 0);
        setProperty("graph-prograss-wings", _wingsgraph);
        setProperty("graph-prograss-springy", false);
        setProperty("graph-prograhint-enable", true);
        setAttribute(Qt::WA_TranslucentBackground);
    }

    void setValue(double process, QString hint=NULL)
    {
        double prograss = property("graph-prograss").toDouble();
        bool springy = property("graph-prograss-springy").toBool();
        if (prograss != process)
        {
            prograss = ceil(process);
            doublefx(process, 1);
            setProperty("graph-prograss", ceil(process));
            if (!hint.isEmpty()) setProperty("graph-prograss-hint", hint);
            if (prograss == 100 && springy) setProperty("graph-prograss-wings", false);
            supdate();
        }
    }

    int value(){
        return property("graph-prograss").toInt();
    }

    void setValue(bool enable)
    {
        setProperty("graph-prograhint-enable", enable);
    }

    void setGraphAttribute(int _radius){
        setProperty("graph-prograss-radius", _radius);
    }

    void setPrograssAttribute(double minnum, double maxnum, double step){
        setProperty("prograss-minnum", minnum);
        setProperty("prograss-maxnum", maxnum);
        setProperty("prograss-step", step);
    }

    void setFormat(QString format)
    {
        setProperty("graph-prograss-format", format);
    }

    void setWingsgraph(bool _wingsgraph, bool _springy = true){
        setProperty("graph-prograss-wings", _wingsgraph);
        setProperty("graph-prograss-springy", _springy);
    }

    void changeEvent(QEvent *event){
        if (event->type() == QEvent::EnabledChange)
        {
            setProperty("graph-prograss", 0);
            setProperty("graph-prograss-hint", "");
        }
        QWidget::changeEvent(event);
    }

protected:

    void paintEvent(QPaintEvent*){
        QPainter impactPainter(this);
        QRect mdl_rect(impactPainter.viewport());
        double prograss = property("graph-prograss").toDouble();
        if (property("graph-prograss-wings").toBool())
        {
            QPainterPath pathall;
            int radius = property("graph-prograss-radius").toInt();
            pathall.addRoundedRect(mdl_rect, radius, radius);
            int prcsswidth = prograss * width() / property("prograss-maxnum").toDouble();
            QRect loadrect(0, 0, ceil(prcsswidth), height());
            impactPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
            impactPainter.setPen(QColor(120,120,120));
            impactPainter.setBrush(Qt::transparent);
            impactPainter.setClipPath(pathall);
            impactPainter.drawRect(mdl_rect);
            impactPainter.setPen(Qt::NoPen);
            QPainterPath pathload;
            pathload.addRoundedRect(loadrect, radius, radius);
            impactPainter.fillPath(pathload, QColor(147,172,208));
        }
        impactPainter.setPen(QColor(120,120,120));
        impactPainter.setFont(QFont("KaiTi_GB2312", height() / 3));
        if (property("graph-prograhint-enable").toBool())
        {
            QString format = property("graph-prograss-format").toString();
            impactPainter.drawText(mdl_rect,
                                   Qt::AlignCenter,
                                   format.arg(prograss).leftJustified(4, ' ') + property("graph-prograss-hint").toString());

        }
    }

private:

    void wheelEvent(QWheelEvent *Event){
        double prograss = property("graph-prograss").toDouble();
        double prgrass_minnum = property("prograss-minnum").toDouble();
        double prgrass_maxnum = property("prograss-maxnum").toDouble();
        double addstep = property("prograss-step").toDouble();
        if (Event->angleDelta().y() > 0)
        {
            if (prograss + addstep <= prgrass_maxnum) prograss += addstep;
        }
        else
        {
            if (prograss - addstep >= prgrass_minnum) prograss -= addstep;
        }
        doublefx(prograss, 1);
        setProperty("graph-prograss", (prograss));
        supdate();
    }

    void mousePressEvent(QMouseEvent *event){
        double prgrass_minnum = property("prograss-minnum").toDouble();
        double prgrass_maxnum = property("prograss-maxnum").toDouble();
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", event->pos());
            double realx = (double)event->position().x() / width() * property("prograss-maxnum").toDouble();
            doublefx(realx, 1);
            if (prgrass_minnum <= realx && realx <= prgrass_maxnum) setProperty("graph-prograss", realx);
            supdate();
        }
    }

    void mouseReleaseEvent(QMouseEvent *event){
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", QPoint(0,0));
        }
    }

    void mouseMoveEvent(QMouseEvent *event){
        QPoint  start_pos = property("start-pos").toPoint();
        double prgrass_minnum = property("prograss-minnum").toDouble();
        double prgrass_maxnum = property("prograss-maxnum").toDouble();
        if (!start_pos.isNull())
        {
            double realx = (double)event->position().x() / width() * property("prograss-maxnum").toDouble();
            doublefx(realx, 1);
            if (prgrass_minnum <= realx && realx <= prgrass_maxnum) setProperty("graph-prograss", realx);
        }
        supdate();
    }

    void supdate(){
        emit positionChange(property("graph-prograss").toDouble());
        update();
    }

    void doublefx(double &value, int place){
        double consult = pow(10.0, place);
        value = round(value * consult) / consult;
    }

signals:
    void positionChange(double position);
};


class NScrollBar : public QScrollBar{

    Q_OBJECT

public:

    NScrollBar(QWidget *parent=nullptr, NT::CST_BRIGHT_SPOT orien=NT::ORIEN_HORIZONTAL) : QScrollBar(parent){
        setParent(parent);
        initialize(orien);
    }

    void setValue(double value, bool signalsend = true){
        if (value >= minimum() && value <= maximum())
        {
            setProperty("graph-prograss", value);
            if (signalsend) emit slidervalue(ceil(property("graph-prograss").toDouble()));
            update();
        }
    }

    double value(){
        return property("graph-prograss").toDouble();
    }

    void d_graph_color(QColor colors = QColor(143,150,163)){
        graphcolor = colors;
    }

    void d_text_color(QColor colors = QColor(240,243,246)){
        textcolor = colors;
    }

    void d_linear_addcolor(QList<QColor> colors = QList<QColor>({QColor(Qt::transparent)})){
        addcolor.swap(colors);
    }

    void d_linear_subcolor(QList<QColor> colors = QList<QColor>({QColor(223,224,228), QColor(200,204,210), QColor(223,224,228)})){
        subcolor.swap(colors);
    }

    void setMaximum(double max){
        maxvalue = max;
    }

    void setMinimum(double min){
        minvalue = min;
    }

    void setRange(double min, double max){
        minvalue = min;
        maxvalue = max;
    }

    void setMaxHpower(double power){
        setProperty("max-power", power);
    }

    void setGraphTextFont(QFont font){
        setProperty("graph-text-font", font);
    }

    int minimum(){
        return minvalue;
    }

    int maximum(){
        return maxvalue;
    }

    double maxHpower(){
        return property("max-power").toDouble();
    }

protected:

    void paintEvent(QPaintEvent*){
        QPainter impactPainter(this);
        int adjustlw;
        impactPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
        double prograss = ceil(property("graph-prograss").toDouble());
        QFont textFont = property("graph-text-font").value<QFont>();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            adjustlw = height() / 4;
        }
        else
        {
            adjustlw = width() / 4;
        }
        int whalf = width() / 2;
        int hhalf = height() / 2;
        int impactprograss;
        int exchangenum;
        int radius;
        QRect graphrect;
        QRect mdlldsubrect;
        QRect mdlldaddrect;
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            radius = hhalf;
            exchangenum = prograss * width() / maxvalue;
            if (exchangenum - hhalf < 0)
            {
                impactprograss = 0;
            }
            else if (exchangenum + hhalf > width())
            {
                impactprograss = width() - height();
            }
            else
            {
                impactprograss = exchangenum - hhalf;
            }
            graphrect.setRect(ceil(impactprograss), 0, height(), height());
            mdlldsubrect.setRect(0, (height() - adjustlw) / 2, ceil(impactprograss), adjustlw);
            mdlldaddrect.setRect(ceil(impactprograss) + height(), (height() - adjustlw) / 2, width(), adjustlw);
        }
        else
        {
            radius = whalf;
            exchangenum = prograss * height() / maxvalue;
            if (exchangenum - whalf < 0) // 如果 起始点减去圆半径小于0，则不再后退，保持圆的边与x轴相贴，避免图形被隐藏
            {
                impactprograss = 0;
            }
            else if (exchangenum + whalf > height())
            {
                impactprograss = height() - width(); //如果起始点加上圆半径大于组件高，则不再累加，保持圆的起始点与x轴有一个直径的距离，避免图形被隐藏
            }
            else
            {
                impactprograss = exchangenum - whalf; //否则正常逻辑下，换算距离需要减去一个半径的高度，即一定程度上，以圆心为准，这体现在点击移动滚动条上
            }
            graphrect.setRect(0, ceil(impactprograss), width(), width());
            mdlldsubrect.setRect((width() - adjustlw) / 2, 0, adjustlw, ceil(impactprograss));
            mdlldaddrect.setRect((width() - adjustlw) / 2, ceil(impactprograss) + width(), adjustlw, height());
        }
        impactPainter.setPen(Qt::NoPen);
        definfc.painterLinear(impactPainter, mdlldsubrect, orientation, subcolor);
        definfc.painterLinear(impactPainter, mdlldaddrect, orientation, addcolor);
        impactPainter.setBrush(graphcolor);
        impactPainter.drawRoundedRect(graphrect, radius, radius);
        impactPainter.setPen(textcolor);
        impactPainter.setFont(textFont);
        impactPainter.drawText(graphrect,
                               Qt::AlignCenter,
                               QString::number(ceil(prograss)));
    }

private:
    Extend definfc;
    QList<QColor> subcolor;
    QList<QColor> addcolor;
    QColor graphcolor;
    QColor textcolor;

    void initialize(NT::CST_BRIGHT_SPOT orien=NT::ORIEN_HORIZONTAL){
        setProperty("graph-orien", orien);
        setProperty("graph-prograss", 0);
        setProperty("max-power", 100);
        setProperty("text-visible", true);
        setProperty("graph-text-font", QFont("KaiTi_GB2312", 11));
        d_graph_color();
        d_text_color();
        d_linear_addcolor();
        d_linear_subcolor();
        setStyleSheet("QScrollBar { background-color: lightgray; }");
    }

    void wheelEvent(QWheelEvent *Event){
        double prograss = property("graph-prograss").toDouble();
        double maxpower = 100 / property("max-power").toDouble();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        double replace_addstep;
        maxpower < 1 ? replace_addstep = 1 : replace_addstep = maxpower;
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            if (Event->angleDelta().y() > 0)
            {
                if (prograss + maxpower <= maxvalue)
                {
                    prograss += replace_addstep;
                }
                else
                {
                    prograss = maxvalue;
                }
            }
            else
            {
                if (prograss - maxpower >= minvalue)
                {
                    prograss -= replace_addstep;
                }
                else
                {
                    prograss = minvalue;
                }
            }
        }
        else
        {
            if (Event->angleDelta().y() < 0)
            {
                if (prograss + maxpower <= maxvalue)
                {
                    prograss += replace_addstep;
                }
                else
                {
                    prograss = maxvalue;
                }
            }
            else
            {
                if (prograss - maxpower >= minvalue)
                {
                    prograss -= replace_addstep;
                }
                else
                {
                    prograss = minvalue;
                }
            }
        }
        doublefx(prograss, 1);
        setProperty("graph-prograss", prograss);
        emit slidervalue(ceil(property("graph-prograss").toDouble()));
        update();
    }

    void mousePressEvent(QMouseEvent *event){
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", event->pos());
            double realnum;
            if (orientation == NT::ORIEN_HORIZONTAL)
            {
                realnum = (double)event->position().x() / width() * maxvalue;
            }
            else
            {
                realnum = (double)event->position().y() / height() * maxvalue;
            }
            doublefx(realnum, 1);
            if (minvalue <= realnum && realnum <= maxvalue) setProperty("graph-prograss", realnum);
            emit slidervalue(ceil(property("graph-prograss").toDouble()));
            update();
        }
    }

    void mouseReleaseEvent(QMouseEvent *event){
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", QPoint(0,0));
            emit slidervalue(ceil(property("graph-prograss").toDouble()));
        }
    }

    void mouseMoveEvent(QMouseEvent *event){
        QPoint  start_pos = property("start-pos").toPoint();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (!start_pos.isNull())
        {
            double realnum;
            if (orientation == NT::ORIEN_HORIZONTAL)
            {
                realnum = (double)event->position().x() / width() * maxvalue;
            }
            else
            {
                realnum = (double)event->position().y() / height() * maxvalue;
            }
            doublefx(realnum, 1);
            if (minvalue <= realnum && realnum <= maxvalue) setProperty("graph-prograss", realnum);
        }
        update();
    }

    void doublefx(double &value, int place){
        double consult = pow(10.0, place);
        value = round(value * consult) / consult;
    }

    double minvalue = 0;
    double maxvalue = 100;

signals:
    void slidervalue(double position);

};


class NSlider : public QWidget{

    Q_OBJECT

public:

    NSlider(QWidget *parent=nullptr, NT::CST_BRIGHT_SPOT orien=NT::ORIEN_HORIZONTAL) : QWidget(parent){
        setParent(parent);
        initialize(orien);
    }

    NSlider(QWidget *parent=nullptr, double step=10, NT::CST_BRIGHT_SPOT orien=NT::ORIEN_HORIZONTAL) : QWidget(parent){
        setParent(parent);
        initialize(orien, step);
    }

    void setValue(double value){
        if (value >= minimum() && value <= maximum())
        {
            setProperty("graph-prograss", value);
            update();
        }
    }

    double value(){
        return property("graph-prograss").toDouble();
    }

    void d_graph_variant(QVariant graphback = QColor(95,136,105), int marginheihgt = 0, QColor secondarycl = QColor(240,243,246)){
        if (graphback.metaType().id() == QMetaType::QColor)
        {
            setProperty("graph-color", graphback);
        }
        else if (graphback.metaType().id() == QMetaType::QPixmap)
        {
            setProperty("graph-pixmap", graphback);
        }
        else if (graphback.metaType().id() == QMetaType::QString)
        {
            QPixmap pixmap;
            pixmap.load(graphback.toString());
            setProperty("graph-pixmap", pixmap);
        }
        setProperty("graph-excursion", marginheihgt);
        setProperty("graph-secondarycl", secondarycl);
    }

    void d_text_visible(bool visible){
        setProperty("text-visible", visible);
    }

    void d_linear_addcolor(QList<QColor> colors = QList<QColor>({QColor(Qt::transparent)})){
        addcolor.swap(colors);
    }

    void d_linear_subcolor(QList<QColor> colors = QList<QColor>({QColor(223,224,228), QColor(200,204,210), QColor(223,224,228)})){
        subcolor.swap(colors);
    }

    void setMaximum(double max){
        maxvalue = max;
    }

    void setMinimum(double min){
        minvalue = min;
    }

    void setRange(double min, double max){
        minvalue = min;
        maxvalue = max;
    }

    void setSingleStep(double step=-1){
        setProperty("advance-step", step);
    }

    int singleStep(){
        return property("advance-step").toInt();
    }

    void setMaxHpower(double power){
        setProperty("max-power", power);
    }

    void setGraphTextFont(QFont font){
        setProperty("graph-text-font", font);
    }

    int minimum(){
        return minvalue;
    }

    long int maximum(){
        return maxvalue;
    }

    double maxHpower(){
        return property("max-power").toDouble();
    }

protected:

    void paintEvent(QPaintEvent*){
        QPainter impactPainter(this);
        impactPainter.setPen(Qt::NoPen);
        int adjustlw;
        impactPainter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
        double prograss = ceil(property("graph-prograss").toDouble());
        QFont textFont = property("graph-text-font").value<QFont>();
        bool textvisible = property("text-visible").toBool();
        int excursion = property("graph-excursion").toInt();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            adjustlw = height() / 4;
        }
        else
        {
            adjustlw = width() / 4;
        }
        int whalf = width() / 2;
        int hhalf = height() / 2;
        int impactprograss;
        int exchangenum;
        int radius;
        QRect graphrect;
        QRect mdlldsubrect;
        QRect mdlldaddrect;
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            radius = hhalf;
            exchangenum = prograss * width() / maxvalue;
            if (exchangenum - hhalf < 0)
            {
                impactprograss = 0;
            }
            else if (exchangenum + hhalf > width())
            {
                impactprograss = width() - height();
            }
            else
            {
                impactprograss = exchangenum - hhalf;
            }
            graphrect.setRect(ceil(impactprograss), 0, height(), height());
            mdlldsubrect.setRect(0, (height() - adjustlw) / 2, ceil(impactprograss), adjustlw);
            mdlldaddrect.setRect(ceil(impactprograss) + height(), (height() - adjustlw) / 2, width(), adjustlw);
        }
        else
        {
            radius = whalf;
            exchangenum = prograss * height() / maxvalue;
            if (exchangenum - whalf < 0) // 如果 起始点减去圆半径小于0，则不再后退，保持圆的边与x轴相贴，避免图形被隐藏
            {
                impactprograss = 0;
            }
            else if (exchangenum + whalf > height())
            {
                impactprograss = height() - width(); //如果起始点加上圆半径大于组件高，则不再累加，保持圆的起始点与x轴有一个直径的距离，避免图形被隐藏
            }
            else
            {
                impactprograss = exchangenum - whalf; //否则正常逻辑下，换算距离需要减去一个半径的高度，即一定程度上，以圆心为准，这体现在点击移动滚动条上
            }
            graphrect.setRect(0, ceil(impactprograss), width(), width());
            mdlldsubrect.setRect((width() - adjustlw) / 2, 0, adjustlw, ceil(impactprograss));
            mdlldaddrect.setRect((width() - adjustlw) / 2, ceil(impactprograss) + width(), adjustlw, height());
        }
        definfc.painterLinear(impactPainter, mdlldsubrect, orientation, subcolor);
        definfc.painterLinear(impactPainter, mdlldaddrect, orientation, addcolor);
        QPixmap pixmap = property("graph-pixmap").value<QPixmap>();
        if (pixmap.isNull())
        {
            QColor graphcolor = property("graph-color").value<QColor>();
            impactPainter.setBrush(graphcolor);
            impactPainter.drawRoundedRect(graphrect, radius, radius);
        }
        else
        {
            if (orientation == NT::ORIEN_HORIZONTAL)
            {
                pixmap.setDevicePixelRatio(pixmap.height() / height());
                impactPainter.drawPixmap(graphrect, pixmap);
            }
            else
            {
                pixmap.setDevicePixelRatio(pixmap.height() / (width() - excursion));
                impactPainter.drawPixmap(graphrect, pixmap);
            }
        }
        if (textvisible)
        {
            impactPainter.setPen(property("graph-secondarycl").value<QColor>());
            impactPainter.setFont(textFont);
            impactPainter.drawText(graphrect,
                                   Qt::AlignCenter,
                                   QString::number(ceil(prograss * 100 / maxvalue)));
        }
    }

private:
    Extend definfc;
    QList<QColor> subcolor;
    QList<QColor> addcolor;

    void initialize(NT::CST_BRIGHT_SPOT orien=NT::ORIEN_HORIZONTAL, double step=10){
        setProperty("graph-orien", orien);
        setProperty("graph-prograss", 0);
        setProperty("max-power", 100);
        setProperty("advance-step", step);
        setProperty("text-visible", true);
        setProperty("graph-text-font", QFont("KaiTi_GB2312", 11));
        d_graph_variant();
        d_linear_addcolor();
        d_linear_subcolor();
    }

    void wheelEvent(QWheelEvent *Event){
        double prograss = property("graph-prograss").toDouble();
        double maxpower = 100 / property("max-power").toDouble();
        double advancestep = property("advance-step").toDouble();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        double replace_addstep;
        if (advancestep < 0)
        {
            maxpower < 1 ? replace_addstep = 1 : replace_addstep = maxpower;
        }
        else
        {
            replace_addstep = advancestep;
        }
        if (orientation == NT::ORIEN_HORIZONTAL)
        {
            if (Event->angleDelta().y() > 0)
            {
                if (prograss + maxpower <= maxvalue)
                {
                    prograss += replace_addstep;
                }
                else
                {
                    prograss = maxvalue;
                }
            }
            else
            {
                if (prograss - maxpower >= minvalue)
                {
                    prograss -= replace_addstep;
                }
                else
                {
                    prograss = minvalue;
                }
            }
        }
        else
        {
            if (Event->angleDelta().y() < 0)
            {
                if (prograss + maxpower <= maxvalue)
                {
                    prograss += replace_addstep;
                }
                else
                {
                    prograss = maxvalue;
                }
            }
            else
            {
                if (prograss - maxpower >= minvalue)
                {
                    prograss -= replace_addstep;
                }
                else
                {
                    prograss = minvalue;
                }
            }
        }
        doublefx(prograss, 1);
        setProperty("graph-prograss", prograss);
        emit slidervalue(ceil(property("graph-prograss").toDouble()));
        update();
    }

    void mousePressEvent(QMouseEvent *event){
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", event->pos());
            double realnum;
            if (orientation == NT::ORIEN_HORIZONTAL)
            {
                realnum = (double)event->position().x() / width() * maxvalue;
            }
            else
            {
                realnum = (double)event->position().y() / height() * maxvalue;
            }
            doublefx(realnum, 1);
            if (minvalue <= realnum && realnum <= maxvalue) setProperty("graph-prograss", realnum);
            emit slidervalue(ceil(property("graph-prograss").toDouble()));
            update();
        }
    }

    void mouseReleaseEvent(QMouseEvent *event){
        if (event->button() == Qt::LeftButton)
        {
            setProperty("start-pos", QPoint(0,0));
            emit slidervalue(ceil(property("graph-prograss").toDouble()));
        }
    }

    void mouseMoveEvent(QMouseEvent *event){
        QPoint  start_pos = property("start-pos").toPoint();
        NT::CST_BRIGHT_SPOT orientation = static_cast<NT::CST_BRIGHT_SPOT>(property("graph-orien").toUInt());
        if (!start_pos.isNull())
        {
            double realnum;
            if (orientation == NT::ORIEN_HORIZONTAL)
            {
                realnum = (double)event->position().x() / width() * maxvalue;
            }
            else
            {
                realnum = (double)event->position().y() / height() * maxvalue;
            }
            doublefx(realnum, 1);
            if (minvalue <= realnum && realnum <= maxvalue) setProperty("graph-prograss", realnum);
        }
        update();
    }

    void doublefx(double &value, int place){
        double consult = pow(10.0, place);
        value = round(value * consult) / consult;
    }

    double minvalue = 0;
    double maxvalue = 100;

signals:
    void slidervalue(double position);
};

#endif
